package spring.demo13.notuse;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.activemq.ActiveMQConnectionFactory;

public class MessageProducerMain {
	public static void main(String[] args) throws JMSException, InterruptedException {
		ConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
		// 创建连接
		Connection cont = connectionFactory.createConnection();
		Session session = cont.createSession(Boolean.TRUE, Session.AUTO_ACKNOWLEDGE);
		// 创建 一个 队列
		Queue queue = session.createQueue("notues_spring");
		// 创建生产者 consumers
		MessageProducer messPro = session.createProducer(queue);
		for (int i = 0; i < 3; i++) {
			TextMessage mess = session.createTextMessage("开始执行：" + i);
			Thread.sleep(100L);
			messPro.send(mess);
		}
		session.commit();
		session.close();
		cont.close();
	}
}
